package com.springcloud.resttemplate.ribbon.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @Desc:
 * @Date: 2020-06-25
 * @Version:v1.0
 */
@Configuration
public class RibbonConfig {

    /**
     * @Desc: Bean 加上 @LoadBalanced注解，此时RsetTemplate 就结合了 Ribbon开启了负载均衡的功能
     * @Param
     * @Return org.springframework.web.client.RestTemplate
     * @Date: 2020/6/25
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
